// -----------------------------------------------------------------------
// <copyright file="SearchContactPeople.aspx.cs" company="Imar.Spaanjaars.Com">
//   Copyright 2008 - 2009 - Imar.Spaanjaars.Com. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Spaanjaars.ContactManager.BusinessEntities;
using System.Web.Security;
using Spaanjaars.ContactManager.Web;

public partial class SearchContactPeople : BasePage
{
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!Page.IsPostBack)
		{
			BindTypeDropDown();
		}
	}

	private void BindTypeDropDown()
	{
		lstType.DataSource = Helpers.GetPersonTypes();
		lstType.DataBind();
	}


	protected void btnSearch_Click(object sender, EventArgs e)
	{
		GridView1.DataBind();
	}

	protected void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
	{
		ContactPersonCriteria myContactPersonCriteria = new ContactPersonCriteria();
		myContactPersonCriteria.FirstName = txtFirstName.Text;
		myContactPersonCriteria.LastName = txtLastName.Text;
		if (!string.IsNullOrEmpty(lstType.SelectedValue))
		{
			myContactPersonCriteria.PersonType = (PersonType)Enum.Parse(typeof(PersonType), lstType.SelectedValue);
		}
		e.InputParameters["contactPersonCriteria"] = myContactPersonCriteria;
	}
}
